/**
 *
 * @param {string} first
 * @param {string} second
 */
function oneEditAway(first, second) {
    if (first === second) return true;
    let loseNumber = 0;
    let index = 0;

    let firstLength = first.length;
    let secondLength = first.length;

    let reversal = first.indexOf(second);

    let length = firstLength > secondLength ? firstLength : secondLength;

    for (
        index = reversal ? length - 1 : 0;
        index < length;
        reversal ? index-- : index++
    ) {
        if (loseNumber >= 2) {
            return false;
        }
        let firstStr = first[index];
        let secondStr = second[index];

        if (firstStr !== secondStr) {
            loseNumber++;
        }
    }

    if (loseNumber >= 2) {
        return false;
    }

    return true;
}
